package com.android.danaobank.mvp.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.android.danaobank.R;
import com.android.danaobank.mvp.fragment.TabCourseFragment;
import com.android.danaobank.mvp.fragment.TabFindFragment;
import com.android.danaobank.mvp.fragment.TabHomeFragment;
import com.android.danaobank.mvp.fragment.TabMallFragment;
import com.android.danaobank.mvp.fragment.TabMineFragment;
import com.android.pdd.baseapp.hometab.BaseBottomFrameLayoutTabActivity;
import com.android.pdd.baseapp.hometab.TabItemView;
import com.blankj.utilcode.util.ToastUtils;
import com.lg.meng.utils.ThreadUtils;

public class HomeActivity extends BaseBottomFrameLayoutTabActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int initTabPosition() {
        return 3;
    }

    @Override
    protected void initTabViews() {
        addTabView(new TabItemView(this, getString(R.string.tab_home),
                R.color.bottom_tab_text_def, R.color.bottom_tab_text_selected,
                R.mipmap.menu_home_normal, R.mipmap.menu_home_selected));
        addTabView(new TabItemView(this, getString(R.string.tab_course),
                R.color.bottom_tab_text_def, R.color.bottom_tab_text_selected,
                R.mipmap.menu_course_normal, R.mipmap.menu_course_selected));
        addTabView(new TabItemView(this, getString(R.string.tab_find),
                R.color.bottom_tab_text_def, R.color.bottom_tab_text_selected,
                R.mipmap.menu_find_normal, R.mipmap.menu_find_selected));
        addTabView(new TabItemView(this, getString(R.string.tab_mall),
                R.color.bottom_tab_text_def, R.color.bottom_tab_text_selected,
                R.mipmap.menu_mall_normal, R.mipmap.menu_mall_selected));
        addTabView(new TabItemView(this, getString(R.string.tab_mine),
                R.color.bottom_tab_text_def, R.color.bottom_tab_text_selected,
                R.mipmap.menu_mine_normal, R.mipmap.menu_mine_selected));
    }

    @Override
    protected void initFragments() {
        addFragment(new TabHomeFragment());
        addFragment(new TabCourseFragment());
        addFragment(new TabFindFragment());
        addFragment(new TabMallFragment());
        addFragment(new TabMineFragment());
    }

    @Override
    public void onBackPressed() {
        if (exit) {
            super.onBackPressed();
        } else {
            exit = true;
            ToastUtils.showShort("再按一次退出应用");
            ThreadUtils.post(2000, () -> {
                exit = false;
            });
        }
    }

    private boolean exit;
}
